

$(function(){
	$('#name').focus();
	$('#selectPro').css('display','none');
	getProviderList();
	setMyActive(5,1); //设置激活页
});

/*获取运营商列表*/
function getProviderList(){
	
	var provider = $("#provider");
	var option = $("<option>").text('无').val('');
	provider.append(option);	
	var myDelUrl = basePath + 'providerList';
	$.ajax({
		type:'get',
		url :myDelUrl,
		data:{ status: '1' },
		success:function (dt){
			$.each(dt, function(index,val) {
		    	option = $("<option id='proId"+index+"'>").text(val.name).val(val.id)
		    	provider.append(option);
		    });
			setSelectStyle(provider);
	    },
	    dataType: 'json'
	});
}

/*
 * 获取省份编码
 * */
function getProvinceCode(type){	
	$('#selectCity').empty;
	$('#selectCity').hide();
	var parent = '';
	if (type == "1") {
		$('#selectPro').show();
		parent = 'CN'
	}
	if (type == "2") {
		$('#provin').empty;
		$('#selectPro').hide();
		parent = 'WD'
	}
	var provin = $("#provin");
	var myDelUrl = basePath + 'provinceCode/' + parent;
	$.ajax({
		type : 'get',
		url : myDelUrl,
		success : function(dt) {
			$.each(dt, function(index, val) {
				option = $("<option >").text(val.name).val(val.code)
				provin.append(option);
			});
			setSelectStyle(provin);
		},
		dataType : 'json'
	});

}

/*
 * 获取城市编码
 * */
function getCityCode(){	
	$('#selectCity').empty;
	$('#selectCity').show();
	var parent=$('#provin option:selected').val();
	var citys = $("#citys");
	var myDelUrl = basePath + 'cityCode/' + parent;
	$.ajax({
		type : 'get',
		url : myDelUrl,
		success : function(dt) {
			$.each(dt, function(index, val) {
				option = $("<option >").text(val.name).val(val.code)
				citys.append(option);
			});
			setSelectStyle(citys);
		},
		dataType : 'json'
	});
}

/*
 * 获取话费包
 * */
function getBillPkgList(providerId){
	$("#billPkg").empty();
	var billPkg = $("#billPkg");
	var myDelUrl = basePath +'billPkgList/'+providerId; 
	$.ajax({
		type:'get',
		url :myDelUrl,
		success:function (dt){
			$.each(dt, function(index,val) {
		    	option = $("<option >").text(val.name).val(val.id)
		    	billPkg.append(option);
		    });
			setSelectStyle(billPkg);
	    },
	    dataType: 'json'
	});
	
}



